/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class RetrieveAndUpdateTaller1PDSData {
	public void retrieveAndUpdateTestData() throws PersistentException {
		PersistentTransaction t = orm.Taller1PDSPersistentManager.instance().getSession().beginTransaction();
		try {
			orm.Pacient lormPacient = orm.PacientDAO.loadPacientByQuery(null, null);
			// Update the properties of the persistent object
			orm.PacientDAO.save(lormPacient);
			orm.User lormUser = orm.UserDAO.loadUserByQuery(null, null);
			// Update the properties of the persistent object
			orm.UserDAO.save(lormUser);
			orm.Doctor lormDoctor = orm.DoctorDAO.loadDoctorByQuery(null, null);
			// Update the properties of the persistent object
			orm.DoctorDAO.save(lormDoctor);
			orm.BabyMonitor lormBabyMonitor = orm.BabyMonitorDAO.loadBabyMonitorByQuery(null, null);
			// Update the properties of the persistent object
			orm.BabyMonitorDAO.save(lormBabyMonitor);
			orm.Solution lormSolution = orm.SolutionDAO.loadSolutionByQuery(null, null);
			// Update the properties of the persistent object
			orm.SolutionDAO.save(lormSolution);
			orm.Diagnose lormDiagnose = orm.DiagnoseDAO.loadDiagnoseByQuery(null, null);
			// Update the properties of the persistent object
			orm.DiagnoseDAO.save(lormDiagnose);
			orm.Response lormResponse = orm.ResponseDAO.loadResponseByQuery(null, null);
			// Update the properties of the persistent object
			orm.ResponseDAO.save(lormResponse);
			orm.Question lormQuestion = orm.QuestionDAO.loadQuestionByQuery(null, null);
			// Update the properties of the persistent object
			orm.QuestionDAO.save(lormQuestion);
			orm.QuestForm lormQuestForm = orm.QuestFormDAO.loadQuestFormByQuery(null, null);
			// Update the properties of the persistent object
			orm.QuestFormDAO.save(lormQuestForm);
			t.commit();
		}
		catch (Exception e) {
			t.rollback();
		}
		
	}
	
	public void retrieveByCriteria() throws PersistentException {
		System.out.println("Retrieving Pacient by PacientCriteria");
		orm.PacientCriteria pacientCriteria = new orm.PacientCriteria();
		// Please uncomment the follow line and fill in parameter(s)
		//pacientCriteria.idPaciente.eq();
		System.out.println(pacientCriteria.uniquePacient());
		
		System.out.println("Retrieving User by UserCriteria");
		orm.UserCriteria userCriteria = new orm.UserCriteria();
		// Please uncomment the follow line and fill in parameter(s)
		//userCriteria.codUser.eq();
		System.out.println(userCriteria.uniqueUser());
		
		System.out.println("Retrieving Doctor by DoctorCriteria");
		orm.DoctorCriteria doctorCriteria = new orm.DoctorCriteria();
		// Please uncomment the follow line and fill in parameter(s)
		//doctorCriteria.idDoctor.eq();
		System.out.println(doctorCriteria.uniqueDoctor());
		
		System.out.println("Retrieving BabyMonitor by BabyMonitorCriteria");
		orm.BabyMonitorCriteria babyMonitorCriteria = new orm.BabyMonitorCriteria();
		// Please uncomment the follow line and fill in parameter(s)
		//babyMonitorCriteria.codSystem.eq();
		System.out.println(babyMonitorCriteria.uniqueBabyMonitor());
		
		System.out.println("Retrieving Solution by SolutionCriteria");
		orm.SolutionCriteria solutionCriteria = new orm.SolutionCriteria();
		// Please uncomment the follow line and fill in parameter(s)
		//solutionCriteria.idSolution.eq();
		System.out.println(solutionCriteria.uniqueSolution());
		
		System.out.println("Retrieving Diagnose by DiagnoseCriteria");
		orm.DiagnoseCriteria diagnoseCriteria = new orm.DiagnoseCriteria();
		// Please uncomment the follow line and fill in parameter(s)
		//diagnoseCriteria.idDiag.eq();
		System.out.println(diagnoseCriteria.uniqueDiagnose());
		
		System.out.println("Retrieving Response by ResponseCriteria");
		orm.ResponseCriteria responseCriteria = new orm.ResponseCriteria();
		// Please uncomment the follow line and fill in parameter(s)
		//responseCriteria.idResponse.eq();
		System.out.println(responseCriteria.uniqueResponse());
		
		System.out.println("Retrieving Question by QuestionCriteria");
		orm.QuestionCriteria questionCriteria = new orm.QuestionCriteria();
		// Please uncomment the follow line and fill in parameter(s)
		//questionCriteria.idQuest.eq();
		System.out.println(questionCriteria.uniqueQuestion());
		
		System.out.println("Retrieving QuestForm by QuestFormCriteria");
		orm.QuestFormCriteria questFormCriteria = new orm.QuestFormCriteria();
		// Please uncomment the follow line and fill in parameter(s)
		//questFormCriteria.idQuestForm.eq();
		System.out.println(questFormCriteria.uniqueQuestForm());
		
	}
	
	
	public static void main(String[] args) {
		try {
			RetrieveAndUpdateTaller1PDSData retrieveAndUpdateTaller1PDSData = new RetrieveAndUpdateTaller1PDSData();
			try {
				retrieveAndUpdateTaller1PDSData.retrieveAndUpdateTestData();
				//retrieveAndUpdateTaller1PDSData.retrieveByCriteria();
			}
			finally {
				orm.Taller1PDSPersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
